
#include "EngineManager.h"
#include "RenderSystemFactory.h"
#include "CoreEngine.h"
#include "RenderEngine.h"
#include "../../CommonLib/src/HelperFunction.h"

namespace FlameEngine
{
	EngineManager* EngineManager::s_pInstance = nullptr;

	EngineManager::EngineManager(char* pCmdLine,IRenderWindow* pRenderWnd)
	{
		assert(s_pInstance == nullptr);

		m_pCoreEngine = new CoreEngine(pCmdLine);
		m_pRenderEngine = new RenderEngine(pRenderWnd);
		
		m_pRenderEngine->Init(m_pCoreEngine);
		m_pCoreEngine->Init(m_pRenderEngine);
		s_pInstance = this;
	}

	EngineManager::~EngineManager()
	{
		SafeDelete(m_pCoreEngine);
		SafeDelete(m_pRenderEngine);

		assert(s_pInstance != nullptr);
		s_pInstance = nullptr;
	}

	void EngineManager::Run()
	{
		m_pCoreEngine->StartRun();
		m_pRenderEngine->StartRun();
	}
}